Introduction

In this report, we are given information on Crime Incident cases that occurred in Dallas, USA in 2016, along with information about the Officer, subject, location, race, date, time, and other metrics.We’ll aim to develop facts and arguments based on logic by investigating the data, and we’ll offer our findings to benefit Dallas, Texas’s legal system.

One of the data sets supplied by the Centre for Policing Equity is the focus of this report, which tries to unearth any hidden insights. The first section is a brief analysis of the shared data. In the later on sections, I did analysis from different perspectives for this data set and then draws a conclusion.

Research Question

The greatest challenge is automatically combining information from the census, police records, and other socioeconomic factors. The unpredictable and confused nature of shapefiles makes it difficult to do things like make guides of police action that incorporate both area line and statistics information. Due to the absence of federal data collection guidelines, normalizing and standardizing police incident data among agencies is particularly challenging. Some of the overarching criteria that will be used to assess are as follows: RQ1: How effective is the method for combining census data with shapefiles? How much manual labor is required? Since CPE will not be able to live-test each submission, a good entry will be able to automate using shape files with multiple projections and properly demonstrate why it is effective at handling the challenge. RQ2: How exact and trustworthy is the investigation given by the proposed arrangement? How well does it link the location of police stations and population density? The best responses will be well-commented and made using the best coding techniques. Every graph and chart needs to be easy to read. Because CPE may use your work to demonstrate where stakeholders should take action, the outputs of your solution should be tailored for an audience of public officials and law enforcement professionals.

The rate of public crime in the United States has been decreasing recently. This is the case, as has been observed. Because of the extensive use of computer-aided technology, the deployment of law enforcement personnel has become more efficient and effective. Huge volumes of data and the computing capability to analyse them have enabled these breakthroughs. There has been a recent uptick in the use of data science by law enforcement agencies as a means of making sense of all that raw information. Recent developments in crime analysis—including pattern reporting, connection studies, and accumulated behaviour displaying—have opened the door to proactive policing and lifesaving foresight. In predictive policing, crime hotspots are dynamically identified using statistical analysis, allowing for the preventative and proactive allocation of police resources. The use of predictive policing is an emerging and exciting field. Accordingly, predictive policing is currently one of the most critical areas of research. But there are many obstacles to overcome before we can develop a really predictive police strategy. When all factors are considered, the best option is the one responsible for data management. How can we effectively collect, analyse, and use this deluge of real-time information? How does one go about making a straightforward yet effective prediction engine? How can we develop a method that can effectively adapt to changing circumstances while consistently producing the same results? The following chapter goes into deeper depth on some of these topics. a review of the potential drawbacks of such a study, along with its aims, methods, and approaches to storing, maintaining, and analysing all facets of crime data. using R, a robust statistical programming language, in its bare-bones configuration for investigating anything.

## Rows: 2384 Columns: 47
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (47): INCIDENT_DATE, INCIDENT_TIME, UOF_NUMBER, OFFICER_ID, OFFICER_GEND...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## # A tibble: 6 × 47
##   INCIDENT_DATE INCIDENT_TIME UOF_NUMBER  OFFICER_ID OFFICER_GENDER OFFICER_RACE
##   <chr>         <chr>         <chr>       <chr>      <chr>          <chr>       
## 1 OCCURRED_D    OCCURRED_T    UOFNum      CURRENT_BA OffSex         OffRace     
## 2 9/3/16        4:14:00 AM    37702       10810      Male           Black       
## 3 3/22/16       11:00:00 PM   33413       7706       Male           White       
## 4 5/22/16       1:29:00 PM    34567       11014      Male           Black       
## 5 1/10/16       8:55:00 PM    31460       6692       Male           Black       
## 6 11/8/16       2:30:00 AM    37879, 378… 9844       Male           White       
## # ℹ 41 more variables: OFFICER_HIRE_DATE <chr>, OFFICER_YEARS_ON_FORCE <chr>,
## #   OFFICER_INJURY <chr>, OFFICER_INJURY_TYPE <chr>,
## #   OFFICER_HOSPITALIZATION <chr>, SUBJECT_ID <chr>, SUBJECT_RACE <chr>,
## #   SUBJECT_GENDER <chr>, SUBJECT_INJURY <chr>, SUBJECT_INJURY_TYPE <chr>,
## #   SUBJECT_WAS_ARRESTED <chr>, SUBJECT_DESCRIPTION <chr>,
## #   SUBJECT_OFFENSE <chr>, REPORTING_AREA <chr>, BEAT <chr>, SECTOR <chr>,
## #   DIVISION <chr>, LOCATION_DISTRICT <chr>, STREET_NUMBER <chr>, …
## spc_tbl_ [2,384 × 47] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
##  $ INCIDENT_DATE                               : chr [1:2384] "OCCURRED_D" "9/3/16" "3/22/16" "5/22/16" ...
##  $ INCIDENT_TIME                               : chr [1:2384] "OCCURRED_T" "4:14:00 AM" "11:00:00 PM" "1:29:00 PM" ...
##  $ UOF_NUMBER                                  : chr [1:2384] "UOFNum" "37702" "33413" "34567" ...
##  $ OFFICER_ID                                  : chr [1:2384] "CURRENT_BA" "10810" "7706" "11014" ...
##  $ OFFICER_GENDER                              : chr [1:2384] "OffSex" "Male" "Male" "Male" ...
##  $ OFFICER_RACE                                : chr [1:2384] "OffRace" "Black" "White" "Black" ...
##  $ OFFICER_HIRE_DATE                           : chr [1:2384] "HIRE_DT" "5/7/14" "1/8/99" "5/20/15" ...
##  $ OFFICER_YEARS_ON_FORCE                      : chr [1:2384] "INCIDENT_DATE_LESS_" "2" "17" "1" ...
##  $ OFFICER_INJURY                              : chr [1:2384] "OFF_INJURE" "No" "Yes" "No" ...
##  $ OFFICER_INJURY_TYPE                         : chr [1:2384] "OFF_INJURE_DESC" "No injuries noted or visible" "Sprain/Strain" "No injuries noted or visible" ...
##  $ OFFICER_HOSPITALIZATION                     : chr [1:2384] "OFF_HOSPIT" "No" "Yes" "No" ...
##  $ SUBJECT_ID                                  : chr [1:2384] "CitNum" "46424" "44324" "45126" ...
##  $ SUBJECT_RACE                                : chr [1:2384] "CitRace" "Black" "Hispanic" "Hispanic" ...
##  $ SUBJECT_GENDER                              : chr [1:2384] "CitSex" "Female" "Male" "Male" ...
##  $ SUBJECT_INJURY                              : chr [1:2384] "CIT_INJURE" "Yes" "No" "No" ...
##  $ SUBJECT_INJURY_TYPE                         : chr [1:2384] "SUBJ_INJURE_DESC" "Non-Visible Injury/Pain" "No injuries noted or visible" "No injuries noted or visible" ...
##  $ SUBJECT_WAS_ARRESTED                        : chr [1:2384] "CIT_ARREST" "Yes" "Yes" "Yes" ...
##  $ SUBJECT_DESCRIPTION                         : chr [1:2384] "CIT_INFL_A" "Mentally unstable" "Mentally unstable" "Unknown" ...
##  $ SUBJECT_OFFENSE                             : chr [1:2384] "CitChargeT" "APOWW" "APOWW" "APOWW" ...
##  $ REPORTING_AREA                              : chr [1:2384] "RA" "2062" "1197" "4153" ...
##  $ BEAT                                        : chr [1:2384] "BEAT" "134" "237" "432" ...
##  $ SECTOR                                      : chr [1:2384] "SECTOR" "130" "230" "430" ...
##  $ DIVISION                                    : chr [1:2384] "DIVISION" "CENTRAL" "NORTHEAST" "SOUTHWEST" ...
##  $ LOCATION_DISTRICT                           : chr [1:2384] "DIST_NAME" "D14" "D9" "D6" ...
##  $ STREET_NUMBER                               : chr [1:2384] "STREET_N" "211" "7647" "716" ...
##  $ STREET_NAME                                 : chr [1:2384] "STREET" "Ervay" "Ferguson" "bimebella dr" ...
##  $ STREET_DIRECTION                            : chr [1:2384] "street_g" "N" "NULL" "NULL" ...
##  $ STREET_TYPE                                 : chr [1:2384] "street_t" "St." "Rd." "Ln." ...
##  $ LOCATION_FULL_STREET_ADDRESS_OR_INTERSECTION: chr [1:2384] "Street Address" "211 N ERVAY ST" "7647 FERGUSON RD" "716 BIMEBELLA LN" ...
##  $ LOCATION_CITY                               : chr [1:2384] "City" "Dallas" "Dallas" "Dallas" ...
##  $ LOCATION_STATE                              : chr [1:2384] "State" "TX" "TX" "TX" ...
##  $ LOCATION_LATITUDE                           : chr [1:2384] "Latitude" "32.782205" "32.798978" "32.73971" ...
##  $ LOCATION_LONGITUDE                          : chr [1:2384] "Longitude" "-96.797461" "-96.717493" "-96.92519" ...
##  $ INCIDENT_REASON                             : chr [1:2384] "SERVICE_TY" "Arrest" "Arrest" "Arrest" ...
##  $ REASON_FOR_FORCE                            : chr [1:2384] "UOF_REASON" "Arrest" "Arrest" "Arrest" ...
##  $ TYPE_OF_FORCE_USED1                         : chr [1:2384] "ForceType1" "Hand/Arm/Elbow Strike" "Joint Locks" "Take Down - Group" ...
##  $ TYPE_OF_FORCE_USED2                         : chr [1:2384] "ForceType2" NA NA NA ...
##  $ TYPE_OF_FORCE_USED3                         : chr [1:2384] "ForceType3" NA NA NA ...
##  $ TYPE_OF_FORCE_USED4                         : chr [1:2384] "ForceType4" NA NA NA ...
##  $ TYPE_OF_FORCE_USED5                         : chr [1:2384] "ForceType5" NA NA NA ...
##  $ TYPE_OF_FORCE_USED6                         : chr [1:2384] "ForceType6" NA NA NA ...
##  $ TYPE_OF_FORCE_USED7                         : chr [1:2384] "ForceType7" NA NA NA ...
##  $ TYPE_OF_FORCE_USED8                         : chr [1:2384] "ForceType8" NA NA NA ...
##  $ TYPE_OF_FORCE_USED9                         : chr [1:2384] "ForceType9" NA NA NA ...
##  $ TYPE_OF_FORCE_USED10                        : chr [1:2384] "ForceType10" NA NA NA ...
##  $ NUMBER_EC_CYCLES                            : chr [1:2384] "Cycles_Num" "NULL" "NULL" "NULL" ...
##  $ FORCE_EFFECTIVE                             : chr [1:2384] "ForceEffec" "Yes" "Yes" "Yes" ...
##  - attr(*, "spec")=
##   .. cols(
##   ..   INCIDENT_DATE = col_character(),
##   ..   INCIDENT_TIME = col_character(),
##   ..   UOF_NUMBER = col_character(),
##   ..   OFFICER_ID = col_character(),
##   ..   OFFICER_GENDER = col_character(),
##   ..   OFFICER_RACE = col_character(),
##   ..   OFFICER_HIRE_DATE = col_character(),
##   ..   OFFICER_YEARS_ON_FORCE = col_character(),
##   ..   OFFICER_INJURY = col_character(),
##   ..   OFFICER_INJURY_TYPE = col_character(),
##   ..   OFFICER_HOSPITALIZATION = col_character(),
##   ..   SUBJECT_ID = col_character(),
##   ..   SUBJECT_RACE = col_character(),
##   ..   SUBJECT_GENDER = col_character(),
##   ..   SUBJECT_INJURY = col_character(),
##   ..   SUBJECT_INJURY_TYPE = col_character(),
##   ..   SUBJECT_WAS_ARRESTED = col_character(),
##   ..   SUBJECT_DESCRIPTION = col_character(),
##   ..   SUBJECT_OFFENSE = col_character(),
##   ..   REPORTING_AREA = col_character(),
##   ..   BEAT = col_character(),
##   ..   SECTOR = col_character(),
##   ..   DIVISION = col_character(),
##   ..   LOCATION_DISTRICT = col_character(),
##   ..   STREET_NUMBER = col_character(),
##   ..   STREET_NAME = col_character(),
##   ..   STREET_DIRECTION = col_character(),
##   ..   STREET_TYPE = col_character(),
##   ..   LOCATION_FULL_STREET_ADDRESS_OR_INTERSECTION = col_character(),
##   ..   LOCATION_CITY = col_character(),
##   ..   LOCATION_STATE = col_character(),
##   ..   LOCATION_LATITUDE = col_character(),
##   ..   LOCATION_LONGITUDE = col_character(),
##   ..   INCIDENT_REASON = col_character(),
##   ..   REASON_FOR_FORCE = col_character(),
##   ..   TYPE_OF_FORCE_USED1 = col_character(),
##   ..   TYPE_OF_FORCE_USED2 = col_character(),
##   ..   TYPE_OF_FORCE_USED3 = col_character(),
##   ..   TYPE_OF_FORCE_USED4 = col_character(),
##   ..   TYPE_OF_FORCE_USED5 = col_character(),
##   ..   TYPE_OF_FORCE_USED6 = col_character(),
##   ..   TYPE_OF_FORCE_USED7 = col_character(),
##   ..   TYPE_OF_FORCE_USED8 = col_character(),
##   ..   TYPE_OF_FORCE_USED9 = col_character(),
##   ..   TYPE_OF_FORCE_USED10 = col_character(),
##   ..   NUMBER_EC_CYCLES = col_character(),
##   ..   FORCE_EFFECTIVE = col_character()
##   .. )
##  - attr(*, "problems")=<externalptr>

SECTION 1: DATA EXPLORATION

The main objective of this report is to achieve or analyze the following objectives The provided dataset contains information on incidents involving police officers and subjects in a specific jurisdiction. The dataset includes 47 variables, including date and time of the incident, officer and subject demographic information, injury and force details, and location information. Regarding officer demographics, the dataset contains details on gender, race, date of recruitment, and number of years of service. Similar to that, subject demographics like ethnicity and gender are given.

## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.1     ✔ purrr     1.0.1
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
## spc_tbl_ [2,384 × 47] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
##  $ INCIDENT_DATE                               : chr [1:2384] "OCCURRED_D" "9/3/16" "3/22/16" "5/22/16" ...
##  $ INCIDENT_TIME                               : chr [1:2384] "OCCURRED_T" "4:14:00 AM" "11:00:00 PM" "1:29:00 PM" ...
##  $ UOF_NUMBER                                  : chr [1:2384] "UOFNum" "37702" "33413" "34567" ...
##  $ OFFICER_ID                                  : chr [1:2384] "CURRENT_BA" "10810" "7706" "11014" ...
##  $ OFFICER_GENDER                              : chr [1:2384] "OffSex" "Male" "Male" "Male" ...
##  $ OFFICER_RACE                                : chr [1:2384] "OffRace" "Black" "White" "Black" ...
##  $ OFFICER_HIRE_DATE                           : chr [1:2384] "HIRE_DT" "5/7/14" "1/8/99" "5/20/15" ...
##  $ OFFICER_YEARS_ON_FORCE                      : chr [1:2384] "INCIDENT_DATE_LESS_" "2" "17" "1" ...
##  $ OFFICER_INJURY                              : chr [1:2384] "OFF_INJURE" "No" "Yes" "No" ...
##  $ OFFICER_INJURY_TYPE                         : chr [1:2384] "OFF_INJURE_DESC" "No injuries noted or visible" "Sprain/Strain" "No injuries noted or visible" ...
##  $ OFFICER_HOSPITALIZATION                     : chr [1:2384] "OFF_HOSPIT" "No" "Yes" "No" ...
##  $ SUBJECT_ID                                  : chr [1:2384] "CitNum" "46424" "44324" "45126" ...
##  $ SUBJECT_RACE                                : chr [1:2384] "CitRace" "Black" "Hispanic" "Hispanic" ...
##  $ SUBJECT_GENDER                              : chr [1:2384] "CitSex" "Female" "Male" "Male" ...
##  $ SUBJECT_INJURY                              : chr [1:2384] "CIT_INJURE" "Yes" "No" "No" ...
##  $ SUBJECT_INJURY_TYPE                         : chr [1:2384] "SUBJ_INJURE_DESC" "Non-Visible Injury/Pain" "No injuries noted or visible" "No injuries noted or visible" ...
##  $ SUBJECT_WAS_ARRESTED                        : chr [1:2384] "CIT_ARREST" "Yes" "Yes" "Yes" ...
##  $ SUBJECT_DESCRIPTION                         : chr [1:2384] "CIT_INFL_A" "Mentally unstable" "Mentally unstable" "Unknown" ...
##  $ SUBJECT_OFFENSE                             : chr [1:2384] "CitChargeT" "APOWW" "APOWW" "APOWW" ...
##  $ REPORTING_AREA                              : chr [1:2384] "RA" "2062" "1197" "4153" ...
##  $ BEAT                                        : chr [1:2384] "BEAT" "134" "237" "432" ...
##  $ SECTOR                                      : chr [1:2384] "SECTOR" "130" "230" "430" ...
##  $ DIVISION                                    : chr [1:2384] "DIVISION" "CENTRAL" "NORTHEAST" "SOUTHWEST" ...
##  $ LOCATION_DISTRICT                           : chr [1:2384] "DIST_NAME" "D14" "D9" "D6" ...
##  $ STREET_NUMBER                               : chr [1:2384] "STREET_N" "211" "7647" "716" ...
##  $ STREET_NAME                                 : chr [1:2384] "STREET" "Ervay" "Ferguson" "bimebella dr" ...
##  $ STREET_DIRECTION                            : chr [1:2384] "street_g" "N" "NULL" "NULL" ...
##  $ STREET_TYPE                                 : chr [1:2384] "street_t" "St." "Rd." "Ln." ...
##  $ LOCATION_FULL_STREET_ADDRESS_OR_INTERSECTION: chr [1:2384] "Street Address" "211 N ERVAY ST" "7647 FERGUSON RD" "716 BIMEBELLA LN" ...
##  $ LOCATION_CITY                               : chr [1:2384] "City" "Dallas" "Dallas" "Dallas" ...
##  $ LOCATION_STATE                              : chr [1:2384] "State" "TX" "TX" "TX" ...
##  $ LOCATION_LATITUDE                           : chr [1:2384] "Latitude" "32.782205" "32.798978" "32.73971" ...
##  $ LOCATION_LONGITUDE                          : chr [1:2384] "Longitude" "-96.797461" "-96.717493" "-96.92519" ...
##  $ INCIDENT_REASON                             : chr [1:2384] "SERVICE_TY" "Arrest" "Arrest" "Arrest" ...
##  $ REASON_FOR_FORCE                            : chr [1:2384] "UOF_REASON" "Arrest" "Arrest" "Arrest" ...
##  $ TYPE_OF_FORCE_USED1                         : chr [1:2384] "ForceType1" "Hand/Arm/Elbow Strike" "Joint Locks" "Take Down - Group" ...
##  $ TYPE_OF_FORCE_USED2                         : chr [1:2384] "ForceType2" NA NA NA ...
##  $ TYPE_OF_FORCE_USED3                         : chr [1:2384] "ForceType3" NA NA NA ...
##  $ TYPE_OF_FORCE_USED4                         : chr [1:2384] "ForceType4" NA NA NA ...
##  $ TYPE_OF_FORCE_USED5                         : chr [1:2384] "ForceType5" NA NA NA ...
##  $ TYPE_OF_FORCE_USED6                         : chr [1:2384] "ForceType6" NA NA NA ...
##  $ TYPE_OF_FORCE_USED7                         : chr [1:2384] "ForceType7" NA NA NA ...
##  $ TYPE_OF_FORCE_USED8                         : chr [1:2384] "ForceType8" NA NA NA ...
##  $ TYPE_OF_FORCE_USED9                         : chr [1:2384] "ForceType9" NA NA NA ...
##  $ TYPE_OF_FORCE_USED10                        : chr [1:2384] "ForceType10" NA NA NA ...
##  $ NUMBER_EC_CYCLES                            : chr [1:2384] "Cycles_Num" "NULL" "NULL" "NULL" ...
##  $ FORCE_EFFECTIVE                             : chr [1:2384] "ForceEffec" "Yes" "Yes" "Yes" ...
##  - attr(*, "spec")=
##   .. cols(
##   ..   INCIDENT_DATE = col_character(),
##   ..   INCIDENT_TIME = col_character(),
##   ..   UOF_NUMBER = col_character(),
##   ..   OFFICER_ID = col_character(),
##   ..   OFFICER_GENDER = col_character(),
##   ..   OFFICER_RACE = col_character(),
##   ..   OFFICER_HIRE_DATE = col_character(),
##   ..   OFFICER_YEARS_ON_FORCE = col_character(),
##   ..   OFFICER_INJURY = col_character(),
##   ..   OFFICER_INJURY_TYPE = col_character(),
##   ..   OFFICER_HOSPITALIZATION = col_character(),
##   ..   SUBJECT_ID = col_character(),
##   ..   SUBJECT_RACE = col_character(),
##   ..   SUBJECT_GENDER = col_character(),
##   ..   SUBJECT_INJURY = col_character(),
##   ..   SUBJECT_INJURY_TYPE = col_character(),
##   ..   SUBJECT_WAS_ARRESTED = col_character(),
##   ..   SUBJECT_DESCRIPTION = col_character(),
##   ..   SUBJECT_OFFENSE = col_character(),
##   ..   REPORTING_AREA = col_character(),
##   ..   BEAT = col_character(),
##   ..   SECTOR = col_character(),
##   ..   DIVISION = col_character(),
##   ..   LOCATION_DISTRICT = col_character(),
##   ..   STREET_NUMBER = col_character(),
##   ..   STREET_NAME = col_character(),
##   ..   STREET_DIRECTION = col_character(),
##   ..   STREET_TYPE = col_character(),
##   ..   LOCATION_FULL_STREET_ADDRESS_OR_INTERSECTION = col_character(),
##   ..   LOCATION_CITY = col_character(),
##   ..   LOCATION_STATE = col_character(),
##   ..   LOCATION_LATITUDE = col_character(),
##   ..   LOCATION_LONGITUDE = col_character(),
##   ..   INCIDENT_REASON = col_character(),
##   ..   REASON_FOR_FORCE = col_character(),
##   ..   TYPE_OF_FORCE_USED1 = col_character(),
##   ..   TYPE_OF_FORCE_USED2 = col_character(),
##   ..   TYPE_OF_FORCE_USED3 = col_character(),
##   ..   TYPE_OF_FORCE_USED4 = col_character(),
##   ..   TYPE_OF_FORCE_USED5 = col_character(),
##   ..   TYPE_OF_FORCE_USED6 = col_character(),
##   ..   TYPE_OF_FORCE_USED7 = col_character(),
##   ..   TYPE_OF_FORCE_USED8 = col_character(),
##   ..   TYPE_OF_FORCE_USED9 = col_character(),
##   ..   TYPE_OF_FORCE_USED10 = col_character(),
##   ..   NUMBER_EC_CYCLES = col_character(),
##   ..   FORCE_EFFECTIVE = col_character()
##   .. )
##  - attr(*, "problems")=<externalptr>
##  INCIDENT_DATE      INCIDENT_TIME       UOF_NUMBER         OFFICER_ID       
##  Length:2384        Length:2384        Length:2384        Length:2384       
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##  OFFICER_GENDER     OFFICER_RACE       OFFICER_HIRE_DATE 
##  Length:2384        Length:2384        Length:2384       
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character  
##  OFFICER_YEARS_ON_FORCE OFFICER_INJURY     OFFICER_INJURY_TYPE
##  Length:2384            Length:2384        Length:2384        
##  Class :character       Class :character   Class :character   
##  Mode  :character       Mode  :character   Mode  :character   
##  OFFICER_HOSPITALIZATION  SUBJECT_ID        SUBJECT_RACE      
##  Length:2384             Length:2384        Length:2384       
##  Class :character        Class :character   Class :character  
##  Mode  :character        Mode  :character   Mode  :character  
##  SUBJECT_GENDER     SUBJECT_INJURY     SUBJECT_INJURY_TYPE SUBJECT_WAS_ARRESTED
##  Length:2384        Length:2384        Length:2384         Length:2384         
##  Class :character   Class :character   Class :character    Class :character    
##  Mode  :character   Mode  :character   Mode  :character    Mode  :character    
##  SUBJECT_DESCRIPTION SUBJECT_OFFENSE    REPORTING_AREA         BEAT          
##  Length:2384         Length:2384        Length:2384        Length:2384       
##  Class :character    Class :character   Class :character   Class :character  
##  Mode  :character    Mode  :character   Mode  :character   Mode  :character  
##     SECTOR            DIVISION         LOCATION_DISTRICT  STREET_NUMBER     
##  Length:2384        Length:2384        Length:2384        Length:2384       
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##  STREET_NAME        STREET_DIRECTION   STREET_TYPE       
##  Length:2384        Length:2384        Length:2384       
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character  
##  LOCATION_FULL_STREET_ADDRESS_OR_INTERSECTION LOCATION_CITY     
##  Length:2384                                  Length:2384       
##  Class :character                             Class :character  
##  Mode  :character                             Mode  :character  
##  LOCATION_STATE     LOCATION_LATITUDE  LOCATION_LONGITUDE INCIDENT_REASON   
##  Length:2384        Length:2384        Length:2384        Length:2384       
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##  REASON_FOR_FORCE   TYPE_OF_FORCE_USED1 TYPE_OF_FORCE_USED2 TYPE_OF_FORCE_USED3
##  Length:2384        Length:2384         Length:2384         Length:2384        
##  Class :character   Class :character    Class :character    Class :character   
##  Mode  :character   Mode  :character    Mode  :character    Mode  :character   
##  TYPE_OF_FORCE_USED4 TYPE_OF_FORCE_USED5 TYPE_OF_FORCE_USED6
##  Length:2384         Length:2384         Length:2384        
##  Class :character    Class :character    Class :character   
##  Mode  :character    Mode  :character    Mode  :character   
##  TYPE_OF_FORCE_USED7 TYPE_OF_FORCE_USED8 TYPE_OF_FORCE_USED9
##  Length:2384         Length:2384         Length:2384        
##  Class :character    Class :character    Class :character   
##  Mode  :character    Mode  :character    Mode  :character   
##  TYPE_OF_FORCE_USED10 NUMBER_EC_CYCLES   FORCE_EFFECTIVE   
##  Length:2384          Length:2384        Length:2384       
##  Class :character     Class :character   Class :character  
##  Mode  :character     Mode  :character   Mode  :character
## # A tibble: 6 × 47
##   INCIDENT_DATE INCIDENT_TIME UOF_NUMBER  OFFICER_ID OFFICER_GENDER OFFICER_RACE
##   <chr>         <chr>         <chr>       <chr>      <chr>          <chr>       
## 1 OCCURRED_D    OCCURRED_T    UOFNum      CURRENT_BA OffSex         OffRace     
## 2 9/3/16        4:14:00 AM    37702       10810      Male           Black       
## 3 3/22/16       11:00:00 PM   33413       7706       Male           White       
## 4 5/22/16       1:29:00 PM    34567       11014      Male           Black       
## 5 1/10/16       8:55:00 PM    31460       6692       Male           Black       
## 6 11/8/16       2:30:00 AM    37879, 378… 9844       Male           White       
## # ℹ 41 more variables: OFFICER_HIRE_DATE <chr>, OFFICER_YEARS_ON_FORCE <chr>,
## #   OFFICER_INJURY <chr>, OFFICER_INJURY_TYPE <chr>,
## #   OFFICER_HOSPITALIZATION <chr>, SUBJECT_ID <chr>, SUBJECT_RACE <chr>,
## #   SUBJECT_GENDER <chr>, SUBJECT_INJURY <chr>, SUBJECT_INJURY_TYPE <chr>,
## #   SUBJECT_WAS_ARRESTED <chr>, SUBJECT_DESCRIPTION <chr>,
## #   SUBJECT_OFFENSE <chr>, REPORTING_AREA <chr>, BEAT <chr>, SECTOR <chr>,
## #   DIVISION <chr>, LOCATION_DISTRICT <chr>, STREET_NUMBER <chr>, …
## # A tibble: 6 × 47
##   INCIDENT_DATE INCIDENT_TIME UOF_NUMBER  OFFICER_ID OFFICER_GENDER OFFICER_RACE
##   <chr>         <chr>         <chr>       <chr>      <chr>          <chr>       
## 1 1/22/16       7:58:00 PM    31754, 320… 9080       Male           White       
## 2 1/3/16        2:22:00 AM    31204       9629       Male           Hispanic    
## 3 2/7/16        3:30:00 PM    32101, 321… 7683       Female         White       
## 4 1/28/16       6:30:00 AM    32018, 320… 9724       Female         White       
## 5 1/9/16        3:30:00 AM    31381, 313… 10068      Male           White       
## 6 1/6/16        10:45:00 PM   31384, 313… 9078       Male           White       
## # ℹ 41 more variables: OFFICER_HIRE_DATE <chr>, OFFICER_YEARS_ON_FORCE <chr>,
## #   OFFICER_INJURY <chr>, OFFICER_INJURY_TYPE <chr>,
## #   OFFICER_HOSPITALIZATION <chr>, SUBJECT_ID <chr>, SUBJECT_RACE <chr>,
## #   SUBJECT_GENDER <chr>, SUBJECT_INJURY <chr>, SUBJECT_INJURY_TYPE <chr>,
## #   SUBJECT_WAS_ARRESTED <chr>, SUBJECT_DESCRIPTION <chr>,
## #   SUBJECT_OFFENSE <chr>, REPORTING_AREA <chr>, BEAT <chr>, SECTOR <chr>,
## #   DIVISION <chr>, LOCATION_DISTRICT <chr>, STREET_NUMBER <chr>, …
##                                INCIDENT_DATE 
##                                            0 
##                                INCIDENT_TIME 
##                                            0 
##                                   UOF_NUMBER 
##                                            0 
##                                   OFFICER_ID 
##                                            0 
##                               OFFICER_GENDER 
##                                            0 
##                                 OFFICER_RACE 
##                                            0 
##                            OFFICER_HIRE_DATE 
##                                            0 
##                       OFFICER_YEARS_ON_FORCE 
##                                            0 
##                               OFFICER_INJURY 
##                                            0 
##                          OFFICER_INJURY_TYPE 
##                                            0 
##                      OFFICER_HOSPITALIZATION 
##                                            0 
##                                   SUBJECT_ID 
##                                            0 
##                                 SUBJECT_RACE 
##                                            0 
##                               SUBJECT_GENDER 
##                                            0 
##                               SUBJECT_INJURY 
##                                            0 
##                          SUBJECT_INJURY_TYPE 
##                                            0 
##                         SUBJECT_WAS_ARRESTED 
##                                            0 
##                          SUBJECT_DESCRIPTION 
##                                            0 
##                              SUBJECT_OFFENSE 
##                                            0 
##                               REPORTING_AREA 
##                                            0 
##                                         BEAT 
##                                            0 
##                                       SECTOR 
##                                            0 
##                                     DIVISION 
##                                            0 
##                            LOCATION_DISTRICT 
##                                            0 
##                                STREET_NUMBER 
##                                            0 
##                                  STREET_NAME 
##                                            0 
##                             STREET_DIRECTION 
##                                            0 
##                                  STREET_TYPE 
##                                            0 
## LOCATION_FULL_STREET_ADDRESS_OR_INTERSECTION 
##                                            0 
##                                LOCATION_CITY 
##                                            0 
##                               LOCATION_STATE 
##                                            0 
##                            LOCATION_LATITUDE 
##                                           55 
##                           LOCATION_LONGITUDE 
##                                           55 
##                              INCIDENT_REASON 
##                                            0 
##                             REASON_FOR_FORCE 
##                                            0 
##                          TYPE_OF_FORCE_USED1 
##                                            0 
##                          TYPE_OF_FORCE_USED2 
##                                          747 
##                          TYPE_OF_FORCE_USED3 
##                                         1510 
##                          TYPE_OF_FORCE_USED4 
##                                         1996 
##                          TYPE_OF_FORCE_USED5 
##                                         2226 
##                          TYPE_OF_FORCE_USED6 
##                                         2322 
##                          TYPE_OF_FORCE_USED7 
##                                         2361 
##                          TYPE_OF_FORCE_USED8 
##                                         2378 
##                          TYPE_OF_FORCE_USED9 
##                                         2382 
##                         TYPE_OF_FORCE_USED10 
##                                         2382 
##                             NUMBER_EC_CYCLES 
##                                            0 
##                              FORCE_EFFECTIVE 
##                                            0

Table/Two-way table

Bringing the dataset into R Studio is the first step. The read.csv() function is used to import the data collection in CSV format. We can assume the dataset was successfully downloaded and is located on our PC in the “Texas.csv” file. Using the head() function, you may see the first few columns of the dataset, giving you a feel for the structure. Next, we’ll make use of the str() method to show off the data set’s structure. This will include the variables’ names, types, and initial values. By outlining the factors in the dataset and the information kinds that they belong to, this will help us decide which plots and graphs to utilise for information research. A frequency chart detailing the ratio of those of each race who were arrested to those who were not will pop up. The number of people of each race who were not detained is also available.

##          
##           American Ind Asian Black CitRace Hispanic NULL Other White
##   CitSex             0     0     0       1        0    0     0     0
##   Female             0     0   274       0       69    4     0    93
##   Male               1     5  1058       0      455   25    11   377
##   NULL               0     0     0       0        0   10     0     0
##   Unknown            0     0     1       0        0    0     0     0
##         
##          American Ind Asian Black Hispanic OffRace Other White
##   Female            2     7    49       42       0     6   134
##   Male              6    48   292      440       0    21  1336
##   OffSex            0     0     0        0       1     0     0

PLOTS To visualise the distribution of a categorical variable, we can use the ggplot2 utility in R to generate a bar or pie chart. Take, as an example, the necessity of creating a bar chart for the “Race” variable. The results of this will be displayed as a bar chart showing the distribution by race. BAR PLOT RACE Using the coord_polar() method found in ggplot2, to are able to generate a pie chart that represents the “SECTOR” variable.

BOX PLOT

# Load the ggplot2 package
library(ggplot2)


# Create a bar plot of the Race variable
ggplot(data = dallas, aes(x = SECTOR)) +
  geom_bar()

For a visual representation of this data, see the pie chart down below. Dot plots can now be generated to demonstrate the spread of continuous data. Create a dot plot of the “Gender” variable to see how the two categories compare, for instance. As a result, a dot plot showing the age distribution of the dataset’s participants will become available. The exploration of data can also make use of various plots and charts. Different types of plots and graphs may be more appropriate depending on the dataset and focus on concerns.

PIE CHART

# Create a pie chart of the Race variable
ggplot(data = dallas, aes(x = "", fill = dallas$SUBJECT_DESCRIPTION)) +
  geom_bar(width = 1) +
  coord_polar(theta = "y")

DENSITY PLOT

Using the ggplot2 package in R, we can create a thickness plot to better appreciate the spread of a constant variable. Think of a scenario in which a thickness guide of the “Orientation” variable might be helpful. A density map will display the range of ages represented in the data set. A thickness plot is a type of chart that depicts the estimated likelihood thickness capabilities of the data to demonstrate the extent to which a variable has spread. To generate the thickness plot, we measure the depth of the data by employing the KDE computation, a non-parametric method for evaluating the probable thickness capacity of an irregular variable.

Using the thickness() feature, you may generate a thickness plot in R Studio. When given a data vector, this function calculates the estimated density and outputs a “density” object. This density object can then be visualised using the plot() method of R or another charting tool. The determined thickness capacity is depicted as a curve in the following figure, where the x-hub represents the variable’s allowed values and the y-pivot represents thickness. The height of the curve and the area under the curve represent the relative probability density at each place. Density charts can be used to spot outliers, see how a distribution is structured, and compare the distributions of many different variables or groups. They can be used in tandem with other plots, such as box plots and histograms, to provide a more complete picture of the data.

# Create a density plot of the gender variable
ggplot(data = dallas, aes(x = SUBJECT_RACE)) +
  geom_density()
## Warning: Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

BOX PLOT

A box plot can be generated to display the distribution of a categorical variable across categories using the ggplot2 tool in R. Consider the case where you are tasked with creating a box plot that incorporates the “Gender” and “Race” variables. A box plot will be used to display the racial breakdown of the age groups in the dataset. The box plot, often called a box-and-whisker plot, is a good example of this sort of story. For studying the distribution of a single variable over different types of data, this tool is invaluable. You may make a box plot in R Studio using the boxplot() function. Each information data vector obtained by the capability (which could be many) results in the generation of a separate case plot. The ensuing phrases paint a picture of a box with “whiskers” and, maybe, individual points outside the whiskers, representing the eventual plot:

# Create a box plot of the gender variable by the Race variable
ggplot(data = dallas, aes(x = OFFICER_YEARS_ON_FORCE, y = OFFICER_INJURY_TYPE)) +
  geom_boxplot()

• The IQR is the range of values between the median and the third quartile of a distribution, and is most often shown as a percentage. The median is depicted by the box’s midpoint, while the first and third quartiles (Q1 and Q3, respectively) are shown by the box’s bottom and top edges). • A box’s whiskers run from its corners to its minimum and maximum values. The stubbles can be located anywhere and are defined by minimum and maximum values within 1.5 times the IQR of the container bounds. Data points that greatly deviate from the mean or median are called whisker outliers and are separated out into their own columns..

SINA PLOT

Sina plots, a type of violin plot, illustrate the distribution of a continuous variable as a function of a categorical one. Unlike the dot plots used in Sina plots, which depict individual data points, violin plots only display the distribution of a continuous variable by a categorical variable. Create a Sina plot using the R package ggbeeswarm. Here’s an example: instance, the scenario in which to wish to generate a Sina plot of the variable denoted by the label “Race.”.

# Load the ggbeeswarm package
library(ggbeeswarm)

# Create a Sina plot of the Gender variable by the Race variable
ggplot(data = dallas, aes(x = OFFICER_GENDER, y = OFFICER_HIRE_DATE)) +
  geom_quasirandom(alpha = 0.5)

SCATTER PLOT

Using the ggplot2 package in R, to are able to generate a scatter plot that will help us visualise the relationship that exists bettoen two continuous variables (Tierney et al., 2018). For illustration’s sake, let’s imagine that to want to make a scatter plot comparing the “Race” variable to the “Years on force” variable. A specific type of plot called a dispersion plot is used to visualise the relationship bettoen two variables. Finding data patterns, trends, and outliers as toll as figuring out whether the variables might be connected in any way are some of its most useful applications. In the end, it can help in locating instances, patterns, and anomalies. By utilising the plot() function in R Studio, you may create a scatter plot of your data. The function creates a scatter plot by requiring two data vectors as input, one for the x-axis and one for the y-axis. The first and second variables are represented by the x- and y-axes of the plot, respectively. Labels, titles, colours, and a number of other graphical features can all be added to the plot to make it your own.

# Create a scatter plot of the race variable against the years on force variable
ggplot(data = dallas, aes(x = dallas$STREET_DIRECTION, y = dallas$SUBJECT_OFFENSE)) +
  geom_point()

# Create a scatter plot of the race variable against the years on force variable
ggplot(data = dallas, aes(x = dallas$DIVISION, y = dallas$LOCATION_DISTRICT)) +
  geom_point()

PAIR PLOT

The ggpairs function found in the GGally package of R can be used to create a pair plot. By doing so, we may examine the interrelationships between the dataset’s many variables. Consider the case in which you need to create a pair plot of the variables “Gender,” “Race,” and “Injury” for both the officer and the subject. A pair plot is a special case of the scatterplot framework or a matches plot. A scatter plot illustrates the interplay between multiple variables at once. Some of its best uses are in spotting out-of-the-ordinary numbers, trends, and correlations in data. A pair plot can be generated in R Studio via the pairs() function. The function takes a data frame as input and returns a matrix of scatter plots depicting the associations between each pair of variables in the data frame as output. The narrative can be made more personal by adding labels, titles, colours, and other graphical aspects.

# Load the GGally package
library(GGally)
## Registered S3 method overwritten by 'GGally':
##   method from   
##   +.gg   ggplot2
ggpairs(data = dallas[, c("SUBJECT_RACE", "SUBJECT_GENDER", "SUBJECT_INJURY")])

ggpairs(data = dallas[, c("OFFICER_RACE", "OFFICER_GENDER", "OFFICER_INJURY")])

CORRELATION ANALYSIS

The cor() function and a heatmap can be used to calculate and visualise the correlation matrix, allowing us to examine the relationships between the continuous variables in the dataset that are associated with one another. Think about the following case: We seek to examine the relationships among the categories of “Gender,” “Race,” “Injury,” “Injury Type,” and “Arrests,” among others. The 2016 Dallas policing dataset was initially loaded into the code using the read.csv() function. The next step is to use the cor() function to determine the correlation matrix between each of the dataset’s numerical variables. When to use the sapply() function to filter out everything but numerical variables. This is significant because the cor() function is the only way to determine the degree of correlation between two numerical variables. After the calculation of the correlation matrix is finished, the matrix is printed to the terminal via the print() function. The last step is to generate a heatmap from the correlation matrix using the ggplot2 and reshape2 software packages. This allows for a more nuanced interpretation of the degree of association between the variables, with higher degrees of red representing stronger associations and lower degrees of blue representing weaker associations. Using the labs() function, you may give your plot a name. In order to learn more about the relationships between the variables that make up a dataset, correlation analysis is a useful tool. As well as highlighting interesting correlations that could be worth further investigation, it allows us to quantify the strength and direction of the relationship between two variables. Connection examination is a factual method for identifying the strength and direction of the straight relationship that exists between at least two factors. Finding patterns and correlations between variables, as well as testing hypotheses and making predictions, are prominent uses of this method in the field of data analysis. You can use R Studio’s cor() function to perform a correlation analysis. Each pair of variables in a dataset will have their correlation coefficient determined by this method. After receiving a data frame as input, the function returns a correlation matrix detailing the coefficients of correlation for each possible pair of variables.

# Calculate the correlation matrix for numeric variables
cor_mat <- cor(dallas[, sapply(dallas, is.numeric)])

# Print the correlation matrix
print(cor_mat)
## <0 x 0 matrix>
# Visualize the correlation matrix as a heatmap
library(ggplot2)
library(reshape2)
## 
## Attaching package: 'reshape2'
## The following object is masked from 'package:tidyr':
## 
##     smiths
ggplot(melt(cor_mat), aes(x = Var1, y = Var2, fill = value)) +
  geom_tile(color = "white") +
  scale_fill_gradient2(low = "blue", high = "red", mid = "white", midpoint = 0) +
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
  labs(title = "Correlation Matrix")

TIME SERIES PLOT

In this code snippet, we first use the read.csv() function to import the policing dataset that was gathered in Dallas in 2016. Following that, a Date object should be created from the date column by calling the as.Date() method with the appropriate format string. Because there are seven days in a toek, the frequency of 7 is used when constructing the time series object via the ts() function. Next, a time series should be displayed using the plot() method, and a major headline should be added to the plot that explains the examined variable. The deconstruct() method will be used to separate the time series into its trend, seasonal, and residual components, so that further analysis of the time series may be conducted. After that, you may plot each variable separately with the help of the plot() method. Data collected over time can be examined for trends and patterns using the study of time series. The time series can be broken down into its component elements to help you better understand the causes of fluctuations in the data and make well-informed decisions about how to respond to them.

# Convert the date column to a Date object
dallas$DATE <- as.Date(dallas$INCIDENT_TIME, format = "%m/%d/%Y")

# Create a time series object
dallas_ts <- ts(dallas$OFFICER_YEARS_ON_FORCE, frequency = 7)

# Plot the time series
plot(dallas_ts, main = "Years on Force with respect to Number of Incidents over Time")
## Warning in xy.coords(x, NULL, log = log, setLab = FALSE): NAs introduced by
## coercion
## Warning in xy.coords(x, y): NAs introduced by coercion

PATTERN/TREND

The 2016 Dallas policing dataset was initially loaded into the code using the read.csv() function. Following that, a Date object should be created from the date column by calling the as.Date() method with the appropriate format string. Create a new plot object using the ggplot2 package, with the DATE column serving as the x-axis and the INCIDENT_NUM column serving as the y-axis. As a result, we may build a trend line chart showing the growing trend of occurrences over time. The next step is to use the geom_smooth() function to incorporate a smooth line into the graph. This line highlights the general upward trend in the data as it develops through time. Applying the same approach as before, this time using the DISTRICT column as a colour palette, is accomplished by using the ggtitle() function to add a primary title to the plot at the very end of the ggplot() procedure. With this information, we can construct a trend line chart showing how many incidents have occurred in each area over time. This produces a unique smoothed line for each ward, which we can then use to evaluate one section of the city against another.

dallas$DATE <- as.Date(dallas$INCIDENT_DATE, format = "%m/%d/%Y")

# Create a smoothed line plot of the number of incidents over time
library(ggplot2)
ggplot(dallas, aes(x = INCIDENT_DATE, y = dallas$SUBJECT_ID)) +
  geom_smooth() +
  ggtitle("Number of Incidents over Time with respect to Subject")
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

SECTION 2: VISUAL APPERANCE

# Load the ggplot2 package
library(ggplot2)


# Create a bar plot of the Race variable
ggplot(data = dallas, aes(x = REASON_FOR_FORCE)) +
  geom_bar()

# Load the ggplot2 package
library(ggplot2)


# Create a bar plot of the Race variable
ggplot(data = dallas, aes(x = REPORTING_AREA)) +
  geom_bar()

# Create a pie chart of the Race variable
ggplot(data = dallas, aes(x = "", fill = LOCATION_DISTRICT)) +
  geom_bar(width = 1) +
  coord_polar(theta = "y")

# Create a pie chart of the Race variable
ggplot(data = dallas, aes(x = "", fill = NUMBER_EC_CYCLES)) +
  geom_bar(width = 1) +
  coord_polar(theta = "y")

table(dallas$INCIDENT_REASON, dallas$REASON_FOR_FORCE)
##                        
##                         Active Aggression Aggressive Animal Arrest
##   Accidental Discharge                  0                 0      0
##   Arrest                              200                 2    656
##   Call for Cover                       14                 0     65
##   Crime in Progress                     4                 0     21
##   Crowd Control                         1                 0      0
##   NULL                                  0                 0      0
##   Off-Duty Employment                  18                 0     17
##   Off-Duty Incident                     5                 0      4
##   Other ( In Narrative)                 8                 1      9
##   Pedestrian Stop                       3                 0      7
##   Service Call                         84                 1    214
##   SERVICE_TY                            0                 0      0
##   Suspicious Activity                   6                 0      9
##   Traffic Stop                          3                 0     39
##   Warrant Execution                     0                 0      9
##                        
##                         Assault to Other Person Barricaded Person
##   Accidental Discharge                        0                 0
##   Arrest                                     22                 3
##   Call for Cover                              2                 1
##   Crime in Progress                           9                 2
##   Crowd Control                               2                 0
##   NULL                                        0                 0
##   Off-Duty Employment                         4                 0
##   Off-Duty Incident                           2                 0
##   Other ( In Narrative)                       1                 0
##   Pedestrian Stop                             1                 0
##   Service Call                               22                 1
##   SERVICE_TY                                  0                 0
##   Suspicious Activity                         0                 0
##   Traffic Stop                                0                 0
##   Warrant Execution                           0                 0
##                        
##                         Crowd Disbursement Danger to self or others
##   Accidental Discharge                   0                        1
##   Arrest                                 1                      136
##   Call for Cover                         0                       26
##   Crime in Progress                      0                        5
##   Crowd Control                          0                        0
##   NULL                                   0                        0
##   Off-Duty Employment                    0                        5
##   Off-Duty Incident                      0                        1
##   Other ( In Narrative)                  0                       14
##   Pedestrian Stop                        0                        6
##   Service Call                           1                      139
##   SERVICE_TY                             0                        0
##   Suspicious Activity                    0                        8
##   Traffic Stop                           0                        6
##   Warrant Execution                      0                        0
##                        
##                         Detention/Frisk NULL Other Property Destruction
##   Accidental Discharge                0    0     0                    0
##   Arrest                             36    0    49                    1
##   Call for Cover                     11    0     6                    0
##   Crime in Progress                   6    0     5                    0
##   Crowd Control                       2    0     0                    0
##   NULL                                0   11     0                    0
##   Off-Duty Employment                 4    0     1                    0
##   Off-Duty Incident                   0    0     0                    0
##   Other ( In Narrative)               9    0    21                    0
##   Pedestrian Stop                    12    0     2                    0
##   Service Call                      101    0    45                    0
##   SERVICE_TY                          0    0     0                    0
##   Suspicious Activity                13    0     5                    1
##   Traffic Stop                       11    0    11                    0
##   Warrant Execution                   1    0     3                    0
##                        
##                         UOF_REASON Weapon Display
##   Accidental Discharge           0              0
##   Arrest                         0             51
##   Call for Cover                 0              6
##   Crime in Progress              0             30
##   Crowd Control                  0              0
##   NULL                           0              0
##   Off-Duty Employment            0              2
##   Off-Duty Incident              0              0
##   Other ( In Narrative)          0              7
##   Pedestrian Stop                0              5
##   Service Call                   0             65
##   SERVICE_TY                     1              0
##   Suspicious Activity            0              5
##   Traffic Stop                   0             23
##   Warrant Execution              0              1
# Bar plot of OFFENSE_TYPE
ggplot(dallas, aes(x = REASON_FOR_FORCE)) +
  geom_bar(fill = "steelblue") +
  labs(title = "Distribution of Offense Types in Dallas, 2016", x = "Offense Type", y = "Count")

SUBJECT RACE

# Pie chart of OFFICER_RACE
ggplot(dallas, aes(x = "", fill = SUBJECT_RACE)) +
  geom_bar(width = 1) +
  coord_polar(theta = "y") +
  labs(title = "Distribution of Officer Races in Dallas, 2016")

ggplot(dallas, aes(x = INCIDENT_TIME)) +
  geom_density(fill = "steelblue") +
  labs(title = "Density Plot of Offense Date and Time in Dallas, 2016", x = "Date and Time", y = "Density")
## Warning: Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Groups with fewer than two data points have been dropped.
## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning
## -Inf

ggplot(dallas, aes(x = OFFICER_INJURY, y = OFFICER_HOSPITALIZATION, fill = OFFICER_RACE)) +
  geom_boxplot() +
  labs(title = "Box Plot of Offense Types by Officer Gender in Dallas, 2016", x = "Officer Gender", y = "Offense Type")

ggplot(dallas, aes(x = INCIDENT_DATE, y = INCIDENT_TIME)) +
  geom_point(alpha = 0.5, color = "steelblue") +
  labs(title = "Scatter Plot of Offense Date and Time vs. Response Time in Dallas, 2016", x = "Offense Date and Time", y = "INCIDENT TIME")

MAP - VISUALIZATION

# Load required packages
library(maps)
## 
## Attaching package: 'maps'
## The following object is masked from 'package:purrr':
## 
##     map
library(ggplot2)

# Get the map data
tx_map <- map_data("county", "texas")

# Plot the map
ggplot(tx_map, aes(x=long, y=lat, group=group)) +
  geom_polygon(fill="Red", color="Blue") +
  theme_void()

SECTION 3

The project “Revealing the Imperceptible: Understanding the Unseen Through the Use of Rstudio Maps” includes an interactive analysis of Dallas police stops in 2016. In this analysis, we studied the 2016 Dallas, Texas police dataset in depth to uncover insights and trends that are often overlooked. By employing Rstudio maps and other methods of information representation, we hope to foster a more intelligent connection. Users can engage with the data in a new and exciting way using this experience. The inner workings of the Dallas policing system in 2016 are revealed by our analysis, which includes demographic breakdowns of drivers and ties to other variables. By highlighting issues that are typically overlooked when it comes to law enforcement and stressing transparency and comprehension as our guiding principles, we hope to initiate conversations about how to build a system that is more equal and egalitarian. Past the Numbers: A Comprehensive Analysis of 2016 Policing in Dallas, Texas Using R Code is the title of this review.goal of this research is to use R’s skills to delve deeply into the Dallas, Texas, 2016 policing dataset, going beyond the statistically superficial statistics generally used in this kind of study. The goal is to use different data visualisation techniques and statistical analysis to look at the connections between things like police officers’ gender and race, the types of crimes that lead to stops, and the locations of stops. In addition, I plan to use R code to further explore the data in an effort to provide insightful information and contribute to the ongoing discussion on the reform of the policing system. By conducting this evaluation, I hope to provide a comprehensive understanding of the Dallas policing landscape in 2016, highlighting both areas of progress and areas needing improvement.

# Beyond the Numbers: An In-Depth Analysis of Policing in Dallas, Texas in 2016 Using R Code

# Load necessary libraries
library(tidyverse)
library(lubridate)
library(ggmap)
## ℹ Google's Terms of Service: <https://mapsplatform.google.com>
## ℹ Please cite ggmap if you use it! Use `citation("ggmap")` for details.
library(ggthemes)

# Load and clean data
dallas <- read_csv("37-00049_UOF-P_2016_prepped.csv") %>%
  mutate(STOP_DATE = mdy_hms(dallas$INCIDENT_DATE))
## Rows: 2384 Columns: 47
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (47): INCIDENT_DATE, INCIDENT_TIME, UOF_NUMBER, OFFICER_ID, OFFICER_GEND...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Warning: There was 1 warning in `mutate()`.
## ℹ In argument: `STOP_DATE = mdy_hms(dallas$INCIDENT_DATE)`.
## Caused by warning:
## ! All formats failed to parse. No formats found.
# Explore data using visualization techniques
ggplot(dallas, aes(x = SUBJECT_RACE, fill = SUBJECT_GENDER)) +
  geom_bar(position = "dodge") +
  ggtitle("Gender and Race of Officers in Dallas in 2016") +
  theme_economist()

ggplot(dallas, aes(x = dallas$SUBJECT_INJURY, fill = dallas$SUBJECT_INJURY_TYPE)) +
  geom_bar(position = "stack") +
  ggtitle("Types of Offenses by Gender of Subject in Dallas in 2016") +
  theme_economist()
## Warning: Use of `dallas$SUBJECT_INJURY` is discouraged.
## ℹ Use `SUBJECT_INJURY` instead.
## Warning: Use of `dallas$SUBJECT_INJURY_TYPE` is discouraged.
## ℹ Use `SUBJECT_INJURY_TYPE` instead.

ggplot(dallas, aes(x = dallas$LOCATION_LATITUDE, y = dallas$LOCATION_LONGITUDE)) +
  geom_point(aes(color = SUBJECT_GENDER)) +
  ggtitle("Location of Stops by Race of Subject in Dallas in 2016") +
  theme_map()
## Warning: Use of `dallas$LOCATION_LATITUDE` is discouraged.
## ℹ Use `LOCATION_LATITUDE` instead.
## Warning: Use of `dallas$LOCATION_LONGITUDE` is discouraged.
## ℹ Use `LOCATION_LONGITUDE` instead.